package com.lanqiao.interceptor;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 演示用的拦截器
 *
 * @author 张建平 on 2020/8/14.
 */
public class ExampleInterceptor implements HandlerInterceptor {

    static Logger logger = Logger.getLogger(ExampleInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        logger.debug(">>> preHandle()\n");
        logger.debug(">>> Handler: " + handler);

        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        logger.debug(">>>> postHandle() \n");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        logger.debug(">>>> afterCompletion()\n");

    }
}
